package com.xiaoxin.experience.util;

import ch.qos.logback.classic.Level;
import ch.qos.logback.classic.Logger;
import ch.qos.logback.classic.LoggerContext;
import org.slf4j.LoggerFactory;

/**
 * @author xiaoxin
 */
public class LogLevelUtil
{

    private static final Logger ROOT_LOGGER;

    static
    {
        LoggerContext loggerContext = (LoggerContext) LoggerFactory.getILoggerFactory();
        ROOT_LOGGER = loggerContext.getLogger("com.xiaoxin");
    }

    public static boolean setLogLevel(String level)
    {
        try
        {
            ROOT_LOGGER.setLevel(Level.toLevel(level));
        }
        catch (Exception e)
        {
            return false;
        }
        return true;
    }

    public static String getLogLevel()
    {
        return ROOT_LOGGER.getLevel().toString();
    }
}
